<template>
    <div>
        <van-nav-bar title="分类" left-text="返回" left-arrow @click-left="() => { $router.back() }" fixed />
        <div style="height: 45px;"></div>
        <van-row>
            <van-col span="6">
                <van-sidebar v-model="active">
                    <van-sidebar-item v-for="item in categoriesApiData" :title="item.cat_name" />
                </van-sidebar></van-col>
            <van-col span="18">
                <div v-for="item in categoriesApiData[active]?.children">
                    <h4>{{ item.cat_name }}</h4>
                    <router-link :to="{name:'goods',params:{query:item.cat_name }}">
                    <!-- <router-link :to="/goods/ + item.cat_name"> -->
                        <van-grid :column-num="4">
                            <van-grid-item v-for="items in item.children" :icon="items.cat_icon"
                                :text="items.cat_name" />
                        </van-grid>
                    </router-link>
                </div>
            </van-col>

        </van-row>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter()
const categoriesApiData = ref([])
import { categoriesApi } from '@/api/api';
categoriesApi().then(res => {
    console.log(res);
    categoriesApiData.value = res.data.message
})
let active = ref(0)
</script>

<style lang="scss" scoped></style>